package com.wshl.cloudservice.ui.widget;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

/**
 * Author：SkySmile
 * Date：2019/10/8
 * Description：加载提示
 */
public class LoadingDialog extends ProgressDialog {
    private static LoadingDialog dialog = null;

    private LoadingDialog(Context context) {
        super(context);
    }

    /**
     * 显示loading
     *
     * @param activity Activity
     * @param msg      提示信息
     */
    public static void showLoading(final Activity activity, final String msg) {
        if (dialog == null) {
            dialog = new LoadingDialog(activity);
            dialog.setCancelable(false);
        }
        dialog.setMessage(msg);
        dialog.show();
    }

    /**
     * 隐藏加载提示
     */
    public static void hideLoading() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
            dialog = null;
        }
    }
}
